var $,element,layer

layui.use(['element','layer'], function() {
    var create=parse("user");//从localStorage里取值
    var mid=create.user_id;

    //定义调用模块
    $ = layui.$,element = layui.element,layer=layui.layer;
    var f=0;
    /*加载垂直导航栏数据*/



    //获取数据
    $.ajax({
        url : "/Navigation/selLoginLog",
        type : "post",
        dataType : "json",
        data : {id:1},
        success : function(data) {
            $(".dept_span").html(data.data[0].dept)
            $(".login_time").html(getDateTime())
            $(".login").html( data.data[0].login_location+"（IP: <span class='login_ip'>"+data.data[0].login_ip+"</span>）")
            $(".agin_time").html(getDate(data.data[0].login_date))
        }
    });



    //var create=parse("user");//从localStorage里取值

    //拼接垂直导航栏
    /*  function addNavigation(data) {
          var Navigation=""
          for(var i=0;i<data.length;i++){

              Navigation+= "<li class='layui-nav-item'> <a data-id='"+ data.menu_id +"' ><i class='layui-icon "+data[i].ihasAuthority_con+"' style='top: 3px;'></i><cite>"+data[i].menu_name+"</cite> </a>"

              if(data[i].children){
                  for(var i1=0;i1<data[i].children.length;i1++){
                      Navigation+="<dl class='layui-nav-child'>";
                      Navigation+="<dd class=''>"
                      if(data[i].children[i1].url==undefined){
                          Navigation+="<a  data-id='"+ data[i].children[i1].menu_id +"'><cite>"+data[i].children[i1].menu_name+"</cite></a>"
                      }else{
                          Navigation+="<a data-id='"+ data[i].children[i1].menu_id +"' href='javascript:;'  _href='"+data[i].children[i1].url+"'><cite>"+data[i].children[i1].menu_name+"</cite></a>"
                      }
                      if(data[i].children[i1].children) {
                          Navigation+= "<dl class='layui-nav-child'>"
                          for (var i2 = 0; i2 < data[i].children[i1].children.length; i2++) {
                              Navigation += "<dd class=''><a data-id='"+  data[i].children[i1].children.menu_id +"' href='javascript:;'  _href='"+data[i].children[i1].children[i2].url+"'><cite>" + data[i].children[i1].children[i2].menu_name + "</cite></a></dd>"
                          }
                          Navigation+= "</dl>"
                      }
                      Navigation+= "</dd>"
                      Navigation+= "</dl>"
                  }
              }
              Navigation+="</li>"
          }
          $(".layui-nav-tree").html(Navigation)
          layui.element.init()
      }*/


    //导航的hover效果、二级菜单等功能，需要依赖element模块
    // larry-side-menu向左折叠
    /*   if($(window).width()<750){
          trun = 0;
      }else{
          trun = 1;
      }
      $('.larry-side-menu').click(function() {
          if(trun){
              $('.x-side').animate({left: '0px'},200).siblings('.x-main').animate({left: '220px'},200);
              trun=0;
          }else{
              $('.x-side').animate({left: '-220px'},200).siblings('.x-main').animate({left: '0px'},200);
              trun=1;
          }
      });
      //监听导航点击
      element.on('nav(side)', function(elem){
          layui.element.init()
          title = elem.find('cite').text();
          url=$(this).attr('_href')
          id1=$(this).attr('data-id')
          if(url!=undefined) {
              createTab(id1, title, url);
          }
      });

      $(".PerUserList").on('click',function(){
          url=$(this).attr('_href')
          id1=$(this).attr('data-id')
          title=$(this).html();
          createTab(id1, title, url);
      })

         //创建选项卡
        function createTab(tabId, con , url) {
            var lis = [];
            $("#tabList #nav li").each(function () {
                lis.push($(this).attr("lay-id"));
            })
            if (lis.length <= 0 || lis.indexOf(tabId) == -1) {
                element.tabAdd('x-tab', {
                    title: con,
                    content: createIframe(url),
                    id: tabId
                });
            }
            //切换选项卡（不需要写else）
            element.tabChange('x-tab', tabId);
        }
        //加载窗体
        function createIframe(url){
            return '<iframe scrolling="yes" src="'+url+'" style="width:100%;height:100%;" frameborder="0" ></iframe>'
        }*/


});


